<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title></title>
		<link href="../../assets/lib/layui/css/layui.css" rel="stylesheet" />
		<link href="../../assets/lib/font-awesome-4.7.0/css/font-awesome.css" rel="stylesheet" />
		<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
		<style type="text/css">
			.edui-editor-iframeholder {
				display: none;
			}
			
			.edui-default .edui-editor-toolbarboxouter {
				border: none! important;
			}
			
			#resultProgressRoot {
				right: -80px;
				bottom: 100px;
				width: 200px;
				z-index: 200;
				position: fixed;
				transform: rotate(90deg);
			}
			
			.progress-label {
				font-size: 14px;
				font-family: "微软雅黑";
				margin: 0px auto;
				text-align: center;
				line-height: 1.4em;
				color: #83AE00;
			}
			
			.progressbarDiv {
				height: 10px! important;
				box-shadow: none! important;
				border: 1px solid #83AE00;
			}
			
			.progressbarDiv .ui-progressbar-value {
				background: #83AE00! important;
				border: none;
			}
			
			.ui-progressbar .ui-progressbar-value {
				margin: 0px;
			}
			
			.ui-progressbar {
				position: relative;
				background: none! important;
			}
			
			.quOptionEditTd .editAble,
			.scoreNumTable tr td,
			.quCoItemTable {
				font-size: 16px;
			}
			
			label.error {
				font-size: 14px;
			}
		</style>
	</head>

	<body style="background-color: RGB(232,233,235);">
		<div id="wrap">

		</div>
		<div class="footer-copyright footer-pb" style="color: gray;padding-bottom: 5px;">
			源码地址:
			<a href="https://gitee.com/doc_wei01_admin/skyeye" style="text-decoration: none;color: gray;">skyeye</a>&nbsp;
		</div>
		<script src="../../assets/lib/layui/layui.js"></script>
		<script src="../../assets/lib/layui/custom.js"></script>
		<script type="text/javascript">
			var quIndex = 0;//问题序号
			var pageNum = 1;//模拟页码
			var nowPageNum = 1;//当前页码
			layui.config({
				base: basePath,
				version: skyeyeVersion
			}).define(['jquery', 'winui', 'validate'], function(exports) {
				winui.renderColor();
				layui.use(['form', 'jqueryUI'], function(form) {
					var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
					var $ = layui.$,
						form = layui.form;

					showGrid({
						id: "wrap",
						url: reqBasePath + "dwsurveydirectory024",
						params: {
							rowId: getUrlParam("rowId")
						},
						pagination: false,
						template: getFileContent('tpl/dwsurveydesign/surveyTemplate.tpl'),
						ajaxSendLoadBefore: function(hdb) {
							hdb.registerHelper("showQuestionIndex", function(v1, options) {
								if(v1 == '16' || v1 == '17'){
								}else{
									quIndex++;
									return quIndex;
								}
							});
							
							hdb.registerHelper("showXhIndex", function(v1, options) {
								return parseInt(v1) + 1;
							});

							hdb.registerHelper("showParamInt02", function(v1, options) {
								var str = "";
								for(var i = 1; i <= v1; i++) {
									str += "<td style='background-color: white;'>" + i + "</td>";
								}
								return str;
							});

							hdb.registerHelper('compare1', function(v1, v2, options) {
								if(v1 == v2) {
									return options.fn(this);
								} else {
									return options.inverse(this);
								}
							});

							hdb.registerHelper('compare2', function(v1, v2, options) {
								if(v1 == v2) {
									return 'display: none;';
								} else {
									return '';
								}
							});

							hdb.registerHelper('compare3', function(v1, v2, options) {
								if(v1 > v2) {
									return options.fn(this);
								} else {
									return options.inverse(this);
								}
							});
							
							hdb.registerHelper('compare4', function(v1, options) {
								if(v1 == nowPageNum) {
									return '';
								} else {
									return 'display: none;';
								}
							});
							
							hdb.registerHelper('compare5', function(v1, options) {
								if(v1 == '16'){
									if(pageNum == '1'){
										pageNum++;
										return '';
									}else{
										pageNum++;
									}
								}
								if(pageNum == '1'){
									return '';
								}else{
									return 'display: none;';
								}
							});
							
							hdb.registerHelper('compare6', function(v1, options) {
								return pageNum;
							});
							
							hdb.registerHelper('compare7', function(v1, options) {
								if(nowPageNum == '1'){
									return options.inverse(this);
								}else{
									return options.fn(this);
								}
							});

							hdb.registerHelper("cellCount001", function(v1, options) {
								var str = "";
								var width = 600 / v1;
								for(var i = 1; i <= v1; i++) {
									str += '<td width="' + width + 'px">' +
										'<div class="dwQuOptionItemContent">' +
										'<label class="dwRedioStyle dwQuInputLabel" ></label>' +
										'<input type="radio" name="qu_{{quType}}_{{quId}}" value="{{id}}" >' +
										'<label style="width:' + (width - 10) + 'px;" class="editAble quCoOptionEdit quCoOptionPadding">{{optionName}}</label>' +
										'<input type="text" class="inputSytle_1" style="width:200px;padding:5px;{{#compare2 isNote 0}}{{/compare2}}" name="text_qu_{{quType}}_{{quId}}_{{id}}" />' +
										'</div>' +
										'</td>';
								}
								str += '<div class="emptyTd"></div>';
								return str;
							});

							hdb.registerHelper("cellCount002", function(v1, options) {
								var str = "";
								var width = 600 / v1;
								for(var i = 1; i <= v1; i++) {
									str += '<td width="' + width + 'px">' +
										'<div class="dwQuOptionItemContent">' +
										'<label class="dwCheckboxStyle dwQuInputLabel" ></label>' +
										'<input type="checkbox" name="tag_qu_{{quType}}_{{quId}}" value="{{id}}" >' +
										'<label style="width:' + (width - 10) + 'px;" class="editAble quCoOptionEdit quCoOptionPadding">{{optionName}}</label>' +
										'<input type="text" class="inputSytle_1" style="width:200px;padding:5px;{{#compare2 isNote 0}}{{/compare2}}" name="text_tag_qu_{{quType}}_{{quId}}_{{id}}" />' +
										'</div>' +
										'</td>';
								}
								str += '<div class="emptyTd"></div>';
								return str;
							});

							hdb.registerHelper("scoreNum001", function(v1, options) {
								var str = "";
								for(var i = 1; i <= v1; i++) {
									str += '<option value="' + i + '">' + i + '分</option>';
								}
								return str;
							});
						},
						ajaxSendAfter: function(json) {

						}
					});

					//获取url中的参数
					function getUrlParam(name) {
						var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
						var r = window.location.search.substr(1).match(reg); //匹配目标参数
						if(r != null) return unescape(r[2]);
						return null; //返回参数值
					}

					//分页设置 nextPage_a prevPage_a
					$(".nextPage_a").click(function() {
						if(validateForms()){
							var thParent = $(this).parent();
							nowPageNum = nowPageNum + 1;
							$(".li_surveyQuItemBody").hide();
							$(".surveyQu_" + nowPageNum).fadeIn("slow");
							$("html,body").animate({
								scrollTop: 10
							}, 500);
							return false;
						}
					});
					$(".prevPage_a").click(function() {
						var thParent = $(this).parent();
						nowPageNum = nowPageNum - 1;
						$(".li_surveyQuItemBody").hide();
						$(".surveyQu_" + nowPageNum).fadeIn("slow");
						$(window).scrollTop(10);
						return false;
					});

					var prevHost = $("#prevHost").val();
					//初始化弹出窗口参数
					var surveyStyleId = $("#surveyStyleId").val();
					if(surveyStyleId != "") {
						/** 背景样式 **/
						var showBodyBi = "${surveyStyle.showBodyBi}";
						var bodyBgColor = "${surveyStyle.bodyBgColor}";
						var bodyBgColorObj = $("input[name='bodyBgColor']");
						bodyBgColorObj.val(bodyBgColor);
						var bodyBCThemeParamObj = bodyBgColorObj.parents(".theme_param");
						bodyBCThemeParamObj.find(".color_box").css({
							"background-color": bodyBgColor
						});
						$("body").css({
							"background-color": bodyBgColor
						});

						var bodyBgImage = "${surveyStyle.bodyBgImage}";
						var bodyBgImageObj = $("input[name='bodyBgImage']");
						var bodyBIThemeParamObj = bodyBgImageObj.parents(".theme_param");
						bodyBgImageObj.val(bodyBgImage);
						bodyBIThemeParamObj.find(".previewImage").attr("src", prevHost + bodyBgImage);
						if(showBodyBi == 1) {
							$("body").css({
								"background-image": "url(" + prevHost + bodyBgImage + ")"
							});
							$("input[name='showBodyBi']").prop("checked", true);
						}

						/** 表头样式 **/
						var showSurveyHbgi = "${surveyStyle.showSurveyHbgi}";
						var surveyHeadBgColor = "${surveyStyle.surveyHeadBgColor}";
						var surveyHeadBgColorObj = $("input[name='surveyHeadBgColor']");
						var surveyHBCThemeParamObj = surveyHeadBgColorObj.parents(".theme_param");
						surveyHeadBgColorObj.val(surveyHeadBgColor);
						surveyHBCThemeParamObj.find(".color_box").css({
							"background-color": surveyHeadBgColor
						});
						$("#dwSurveyHeader").css({
							"background-color": surveyHeadBgColor
						});

						var surveyHeadBgImage = "${surveyStyle.surveyHeadBgImage}";
						var surveyHeadBgImageObj = $("input[name='surveyHeadBgImage']");
						var surveyHBIThemeParamObj = surveyHeadBgImageObj.parents(".theme_param");
						surveyHeadBgImageObj.val(surveyHeadBgImage);
						surveyHBIThemeParamObj.find(".previewImage").attr("src", prevHost + surveyHeadBgImage);
						if(showSurveyHbgi == 1) {
							$("#dwSurveyHeader").css({
								"background-image": "url(" + prevHost + surveyHeadBgImage + ")"
							});
							$("input[name='showSurveyHbgi']").prop("checked", true);
						}

						var surveyHeadPaddingTop = "${surveyStyle.surveyHeadPaddingTop}";
						var surveyHeadPaddingBottom = "${surveyStyle.surveyHeadPaddingBottom}";
						$("#dwSurveyHeader").css({
							"padding-top": surveyHeadPaddingTop + "px"
						});
						$("#dwSurveyHeader").css({
							"padding-bottom": surveyHeadPaddingBottom + "px"
						});

						/** 内容中间样式 **/
						var showSurveyCbim = "${surveyStyle.showSurveyCbim}";
						var surveyContentBgColorMiddle = "${surveyStyle.surveyContentBgColorMiddle}";
						var surveyContentBgColorMiddleObj = $("input[name='surveyContentBgColorMiddle']");
						var surveyCBCMThemeParamObj = surveyContentBgColorMiddleObj.parents(".theme_param");
						surveyContentBgColorMiddleObj.val(surveyContentBgColorMiddle);
						surveyCBCMThemeParamObj.find(".color_box").css({
							"background-color": surveyContentBgColorMiddle
						});;
						$("#dwSurveyQuContentBg").css({
							"background-color": surveyContentBgColorMiddle
						});

						var surveyContentBgImageMiddle = "${surveyStyle.surveyContentBgImageMiddle}";
						var surveyContentBgImageMiddleObj = $("input[name='surveyContentBgImageMiddle']");
						var surveyCBIMThemeParamObj = surveyContentBgImageMiddleObj.parents(".theme_param");
						surveyContentBgImageMiddleObj.val(surveyContentBgImageMiddle);
						surveyCBIMThemeParamObj.find(".previewImage").attr("src", prevHost + surveyContentBgImageMiddle);
						if(showSurveyCbim == 1) {
							$("#dwSurveyQuContentBg").css({
								"background-image": "url(" + prevHost + surveyContentBgImageMiddle + ")"
							});
							$("input[name='showSurveyCbim']").prop("checked", true);
						}

						/** 文本样式 **/
						var questionTitleTextColor = "${surveyStyle.questionTitleTextColor}";
						var questionTitleTextColorObj = $("input[name='questionTitleTextColor']");
						var questionTTCThemeParamObj = questionTitleTextColorObj.parents(".theme_param");
						questionTitleTextColorObj.val(questionTitleTextColor);
						questionTTCThemeParamObj.find(".color_box").css({
							"background-color": questionTitleTextColor
						});
						$(".quCoTitle").css({
							"color": questionTitleTextColor
						});

						var questionOptionTextColor = "${surveyStyle.questionOptionTextColor}";
						var questionOptionTextColorObj = $("input[name='questionOptionTextColor']");
						var questionOTCThemeParamObj = questionOptionTextColorObj.parents(".theme_param");
						questionOptionTextColorObj.val(questionOptionTextColor);
						questionOTCThemeParamObj.find(".color_box").css({
							"background-color": questionOptionTextColor
						});
						$(".quCoOptionEdit").css({
							"color": questionOptionTextColor
						});

						var surveyTitleTextColor = "${surveyStyle.surveyTitleTextColor}";
						var surveyTitleTextColorObj = $("input[name='surveyTitleTextColor']");
						var surveyTTCThemeParamObj = surveyTitleTextColorObj.parents(".theme_param");
						surveyTitleTextColorObj.val(surveyTitleTextColor);
						surveyTTCThemeParamObj.find(".color_box").css({
							"background-color": surveyTitleTextColor
						});
						$("#dwSurveyTitle").css({
							"color": surveyTitleTextColor
						});

						var surveyNoteTextColor = "${surveyStyle.surveyNoteTextColor}";
						var surveyNoteTextColorObj = $("input[name='surveyNoteTextColor']");
						var surveyNTCThemeParamObj = surveyNoteTextColorObj.parents(".theme_param");
						surveyNoteTextColorObj.val(surveyNoteTextColor);
						surveyNTCThemeParamObj.find(".color_box").css({
							"background-color": surveyNoteTextColor
						});
						$("#dwSurveyNoteEdit").css({
							"color": surveyNoteTextColor
						});

						var surveyBtnBgColor = "${surveyStyle.surveyBtnBgColor}";
						if(surveyBtnBgColor !== "") {
							$("#dw_body_content .sbtn24,.progressbarDiv .ui-progressbar-value").css({
								"background-color": surveyBtnBgColor
							});
							$(".progressbarDiv").css({
								"border-color": surveyBtnBgColor
							});
							$(".progress-label ").css({
								"color": surveyBtnBgColor
							});
							var surveyBtnBgColorObj = $("input[name='surveyBtnBgColor']");
							surveyBtnBgColorObj.val(surveyBtnBgColor);
							var btnBcThemeParamObj = surveyBtnBgColorObj.parents(".theme_param");
							btnBcThemeParamObj.find(".color_box").css({
								"background-color": surveyBtnBgColor
							});
						}

						//显示序号及进度条
						var showTiNum = "${surveyStyle.showTiNum}";
						var showProgressbar = "${surveyStyle.showProgressbar}";
						if(showTiNum == 0) {
							$(".quCoNum").hide();
						}
						if(showProgressbar == 0) {
							$("#resultProgressRoot").hide();
						}

						//表头文本显示
						var showSurTitle = "${surveyStyle.showSurTitle}";
						var showSurNote = "${surveyStyle.showSurNote}";
						if(showSurTitle == 0) {
							$("#dwSurveyTitle").hide();
						}
						if(showSurNote == 0) {
							$("#dwSurveyNote").hide();
						}
					}

					$(".submitSurvey").click(function() {
						if(validateForms()) {
							$("#surveyForm").submit();
						}
						return false;
					});

					//评分题
					$(".scoreNumTable tr td").click(function() {
						var quScoreOptionTr = $(this).parents(".quScoreOptionTr");
						var tdText = $(this).text();
						quScoreOptionTr.find(".scoreNumTable tr td").css({
							"background": "white"
						});
						quScoreOptionTr.find(".scoreNumText").html($(this).text() + "&nbsp;分");

						$(this).prevAll().css({
							"background": ""
						});
						$(this).css({
							"background": ""
						});

						quScoreOptionTr.find(".scoreNumInput").val(tdText);
						quScoreOptionTr.find(".scoreNumText").html(tdText + "&nbsp;分");

						runlogic($(this));
						answerProgressbar($(this));
						validateCheck($(this).parents(".li_surveyQuItemBody"), false);
					});

					bindScoreNumTdHover();

					function bindScoreNumTdHover() {
						$(".scoreNumTable tr td").hover(function() {
							var quScoreOptionTr = $(this).parents(".quScoreOptionTr");
							var scoreNumInput = quScoreOptionTr.find(".scoreNumInput").val();
							if(scoreNumInput == "") {
								$(this).prevAll().css({
									"background": ""
								});
								$(this).css({
									"background": ""
								});
								quScoreOptionTr.find(".scoreNumText").html($(this).text() + "&nbsp;分");
							}
						}, function() {
							var quScoreOptionTr = $(this).parents(".quScoreOptionTr");
							var scoreNumInput = quScoreOptionTr.find(".scoreNumInput").val();
							if(scoreNumInput == "") {
								$(this).prevAll().css({
									"background": "white"
								});
								$(this).css({
									"background": "white"
								});
								quScoreOptionTr.find(".scoreNumText").html("分");
							}
						});
					}

					//排序题
					bindQuOrderBySorts();

					function bindQuOrderBySorts() {
						var quOrderByCoItems = $(".quOrderByCoItem");
						$.each(quOrderByCoItems, function() {
							$(this).find(".quOrderByLeftUl li").sortable({
								zIndex: 1000,
								scroll: false,
								opacity: 0.8,
								placeholderType: false,
								connectWith: $(this).find(".quOrderByTable td"),
								helper: function(event, ui) {
									return "<label class='quOrderItemLabel'>" + $(this).text() + "</label>";
								},
								over: function(event, ui) {

								},
								start: function(event, ui) {

								},
								drag: function(event, ui) {

								},
								stop: function(event, ui) {
									$(".quOrderByTable td").css({
										"background": ""
									});
									answerProgressbar($(this));
									validateCheck($(this).parents(".li_surveyQuItemBody"), false);
								}
							});
							var sortObjTempHtml = null;
							$(this).find(".quOrderByTable td").sortable({
								zIndex: 1000,
								scroll: false,
								opacity: 0.9,
								placeholderType: true,
								placeholder: "qu-order-highlight",
								connectWith: $(this).find(".quOrderByTable td"),
								over: function(event, ui) {
									$(".quOrderByTable td").css({
										"background": ""
									});
									$(this).css({
										"background": "#FAEDC0"
									});
									var quOrderItemLabel = $(this).find("label.quOrderItemLabel");
									sortObjTempHtml = "";
									if(quOrderItemLabel[0]) {
										sortObjTempHtml = quOrderItemLabel.html();
									}
								},
								receive: function(event, ui) { //当一个已连接的sortable对象接收到另一个sortable对象的元素后触发此事件。
									//判断如果是从右边新移入的，但当前td中已经有了，就交换到右边去
									var uiSenderClass = ui.sender.attr("class");
									ui.sender.empty();
									if(uiSenderClass.indexOf("quCoItemUlLi") < 0) {
										if(sortObjTempHtml != "") {
											ui.sender.append("<label class='quOrderItemLabel'>" + sortObjTempHtml + "</label>");
										}
									} else {
										if(sortObjTempHtml != "") {
											ui.sender.append("<label class='editAble quCoOptionEdit'>" + sortObjTempHtml + "</label>");
										}
									}

									$(this).empty();
									ui.item.clone().appendTo($(this));
									var quCoOptionEdit = $(this).find(".quCoOptionEdit");
									if(quCoOptionEdit[0]) {
										quCoOptionEdit.removeClass();
										quCoOptionEdit.addClass("quOrderItemLabel");
									}
									$(".quOrderByTable td").css({
										"background": ""
									});
									//更新排序ID  quCoItem quOrderByTableTr
									var quOrderyByTrs = $(".quCoItem .quOrderByTableTr");
									$.each(quOrderyByTrs, function(i) {
										var quOrderItemHidInput = $(this).find(".quOrderItemHidInput");
										quOrderItemHidInput.val(i + 1);
									});
								},
								start: function(event, ui) {
									$(".quOrderByTable td").css({
										"background": ""
									});
									$(this).css({
										"background": "#FAEDC0"
									});
								},
								drag: function(event, ui) {
									$(".quOrderByTable td").css({
										"background": ""
									});
									$(this).css({
										"background": "#FAEDC0"
									});
								},
								stop: function(event, ui) {
									$(".quOrderByTable td").css({
										"background": ""
									});
								},
								out: function(event, ui) {},
								activate: function(event, ui) {}
							});
						});
					}

					/**初始化表单骓证配置**/
					function validateForms() {
						var result = true;
						var surveyQuItemBodys = $(".li_surveyQuItemBody");
						var firstError = null;
						$.each(surveyQuItemBodys, function() {
							var quItemBody = $(this);
							if(!validateCheck(quItemBody, true)) {
								//定位到这题 
								if(firstError == null) {
									firstError = quItemBody;
								}
								result = false;
							}
						});
						if(firstError != null) {
							$(window).scrollTop(firstError.offset().top);
						}
						if($("#jcaptchaImgBody").is(":visible")) {
							var jcaptchaInput = $("input[name='jcaptchaInput']").val();
							if(jcaptchaInput === "") {
								$("#jcaptchaImgBody .errorItem").show();
								result = false;
							} else {
								$("#jcaptchaImgBody .errorItem").hide();
							}
						}
						return result;
					}

					function validateCheck(quItemBody, isSubForm) {
						if(quItemBody.is(":visible")) {
							var quId = quItemBody.find(".quId").val();
							var quType = quItemBody.find(".quType").val();
							var isRequired = quItemBody.find(".isRequired").val();
							var validateStatus = false;
							if(isRequired === "0") {
								validateStatus = true;
								return true;
							}
							if(quType === "RADIO") {
								validateStatus = quItemBody.find("input[type='radio']:checked")[0];
							} else if(quType === "CHECKBOX") {
								validateStatus = quItemBody.find("input[type='checkbox']:checked")[0];
							} else if(quType === "FILLBLANK") {
								validateStatus = quItemBody.find(".fillblankInput").val() != "";
							} else if(quType === "ORDERQU") {
								validateStatus = !quItemBody.find(".quOrderByLeftUl label")[0];
							} else if(quType === "SCORE") {
								validateStatus = true;
								var quScoreOptionTrs = quItemBody.find(".quScoreOptionTr");
								$.each(quScoreOptionTrs, function() {
									var scoreNumInput = $(this).find(".scoreNumInput");
									if(scoreNumInput.val() === "") {
										validateStatus = false;
										return false;
									}
								});
							} else if(quType === "MULTIFILLBLANK") {
								validateStatus = true;
								var quScoreOptionTrs = quItemBody.find(".mFillblankTableTr");
								$.each(quScoreOptionTrs, function() {
									var scoreNumInput = $(this).find(".dwMFillblankInput");
									if(scoreNumInput.val() === "") {
										validateStatus = false;
										return false;
									}
								});
							} else if(quType === "CHENRADIO") {
								validateStatus = true;
								var quScoreOptionTrs = quItemBody.find(".dwQuCoChenRowTr");
								$.each(quScoreOptionTrs, function() {
									var tempInputs = $(this).find(".checked");
									if(!tempInputs[0]) {
										validateStatus = false;
										return false;
									}
								});
							} else if(quType === "CHENCHECKBOX") {
								validateStatus = true;
								var quScoreOptionTrs = quItemBody.find(".dwQuCoChenRowTr");
								$.each(quScoreOptionTrs, function() {
									var tempInputs = $(this).find("input[type='checkbox']:checked");
									if(!tempInputs[0]) {
										validateStatus = false;
										return false;
									}
								});
							} else if(quType === "CHENSCORE") {
								var quChenScores = quItemBody.find(".quChenScoreSelect");
								validateStatus = true;
								$.each(quChenScores, function() {
									var tempInputs = $(this);
									if(tempInputs.val() === "0") {
										validateStatus = false;
										return false;
									}
								});
							} else if(quType === "CHENFBK") {
								var dwCMFBKs = quItemBody.find(".dwChenMFillblankInput");
								validateStatus = true;
								$.each(dwCMFBKs, function() {
									var tempInputs = $(this);
									if(tempInputs.val() === "") {
										validateStatus = false;
										return false;
									}
								});
							} else if(quType === "submitSurveyBtn" || quType === "PARAGRAPH" || quType === "PAGETAG") {
								return true;
							}
						} else {
							validateStatus = true;
						}
						if(validateStatus) {
							quItemBody.find(".errorItem").remove();
						} else {
							if(isSubForm && !quItemBody.find(".errorItem")[0]) {
								var errorHtml = "<div class=\"errorItem\"><label for=\"\" class=\"error\">请检查题目答案，为必答项！</label></div>";
								quItemBody.find(".quCoItem").append(errorHtml);
							}
						}
						return validateStatus;
					}

					/******************************处理题目逻辑设置 **************************************/
					//初始化 处理默认逻辑跳转为显示，则先隐藏元素
					var quLogics = $("#dwSurveyQuContent .quLogicItem");
					$.each(quLogics, function() {
						var loginItem = $(this);
						var cgQuItemId = loginItem.find(".cgQuItemId").val();
						var skQuId = loginItem.find(".skQuId").val();
						var logicId = loginItem.find(".logicId").val();
						var logicType = loginItem.find(".logicType").val();
						if(logicType === "2") {
							//逻辑类型为“显示”2  则初始化为隐藏
							var hidQuItemBody = $(".quId[value='" + skQuId + "']").parents(".li_surveyQuItemBody");
							hidQuItemBody.hide();
							hidQuItemBody.addClass("hidFor" + logicId);
							hidQuItemBody.find(".answerTag").attr("disabled", true);
						}
					});

					/** 单选与多选条件触发 自定义单选多选效果 操作结束后得调用逻辑判断 **/
					$(".dwQuOptionItemContent").click(function() {
						var thObj = $(this);
						var quItemBody = thObj.parents(".li_surveyQuItemBody");
						var quType = quItemBody.find(".quType").val();
						var dwQuInputLabel = thObj.find(".dwQuInputLabel");
						if("RADIO" === quType) {
							//单选题
							quItemBody.find(".dwQuInputLabel").removeClass("checked");
							quItemBody.find("input[type='radio']").prop("checked", false);
							dwQuInputLabel.addClass("checked");
							thObj.find("input[type='radio']").prop("checked", true);
							runlogic(thObj.find("input[type='radio']"));
						} else if("CHECKBOX" === quType) {
							//多选题
							var quInputLabelClass = dwQuInputLabel.attr("class");
							if(quInputLabelClass.indexOf("checked") > 0) {
								dwQuInputLabel.removeClass("checked");
								thObj.find("input[type='checkbox']").prop("checked", false);
							} else {
								dwQuInputLabel.addClass("checked");
								thObj.find("input[type='checkbox']").prop("checked", true);
							}
							runlogic(thObj.find("input[type='checkbox']"));
						} else if("CHENRADIO" === quType) {
							//矩陈单选
							var chenRow = thObj.parents("tr");
							chenRow.find(".dwQuInputLabel").removeClass("checked");
							chenRow.find("input[type='radio']").prop("checked", false);
							dwQuInputLabel.addClass("checked");
							thObj.find("input[type='radio']").prop("checked", true);
							runlogic(thObj.find("input[type='radio']"));
						} else if("CHENCHECKBOX" === quType) {
							//矩陈多选
							var quInputLabelClass = dwQuInputLabel.attr("class");
							if(quInputLabelClass.indexOf("checked") > 0) {
								dwQuInputLabel.removeClass("checked");
								thObj.find("input[type='checkbox']").prop("checked", false);
							} else {
								dwQuInputLabel.addClass("checked");
								thObj.find("input[type='checkbox']").prop("checked", true);
							}
							runlogic(thObj.find("input[type='checkbox']"));
						}
						answerProgressbar(thObj);
						validateCheck(quItemBody, false);
					});

					//填空题
					$(".fillblankInput,.dwMFillblankInput,.dwChenMFillblankInput").blur(function() {
						var thVal = $(this).val();
						runlogic($(this));
						answerProgressbar($(this));
						validateCheck($(this).parents(".li_surveyQuItemBody"), false);
					});

					$(".quChenScoreSelect").change(function() {
						answerProgressbar($(this));
						validateCheck($(this).parents(".li_surveyQuItemBody"), false);
					});

					//只要触发事件
					function runlogic(thFormElementObj) {
						var quItemBody = thFormElementObj.parents(".li_surveyQuItemBody");
						var quLogicItems = quItemBody.find(".quLogicItem");
						if(quLogicItems[0]) {
							var quInputCase = quItemBody.find(".quInputCase");
							var quId = quInputCase.find(".quId").val();
							var quType = quInputCase.find(".quType").val();
							if(quType === "RADIO" || quType === "CHECKBOX" || quType === "SCORE" || quType === "MULTIFILLBLANK" || quType === "CHENRADIO" || quType === "CHENCHECKBOX" || quType === "CHENSCORE" || quType === "CHENFBK") {
								//判断是否选中
								var quLgoicItem = null;
								//遍历每个逻辑设置
								var quOptionItems = null;
								if(quType === "RADIO" || quType === "CHECKBOX") {
									quOptionItems = quItemBody.find(".dwQuOptionItemContent");
								} else if(quType === "SCORE") {
									quOptionItems = quItemBody.find(".quScoreOptionTr");
								} else if(quType === "MULTIFILLBLANK") {
									quOptionItems = quItemBody.find(".mFillblankTableTr");
								} else if(quType === "CHENRADIO" || quType === "CHENCHECKBOX") {
									quOptionItems = quItemBody.find(".dwQuOptionItemContent");
								} else if(quType === "CHENFBK") {
									quOptionItems = quItemBody.find(".dwQuChenFbkOptionItemContent");
								}
								$.each(quLogicItems, function() {
									var loginItem = $(this);
									var cgQuItemId = loginItem.find(".cgQuItemId").val();
									var skQuId = loginItem.find(".skQuId").val();
									var logicId = loginItem.find(".logicId").val();
									var logicType = loginItem.find(".logicType").val();
									var geLe = null;
									var scoreNum = null;
									if(quType === "SCORE") {
										geLe = loginItem.find(".geLe").val();
										scoreNum = loginItem.find(".scoreNum").val();
									}
									//过滤优先级
									var isbreak = false;
									$.each(quOptionItems, function() {
										var quCoItem = $(this);
										var quInput = null;
										var logicStatus = false;
										var curQuItemId = null;
										if(quType === "RADIO") {
											quInput = quCoItem.find("input[type='radio']");
											logicStatus = quInput.prop("checked");
											curQuItemId = quInput.val();
										} else if(quType === "CHECKBOX") {
											quInput = quCoItem.find("input[type='checkbox']");
											logicStatus = quInput.prop("checked");
											curQuItemId = quInput.val();
										} else if(quType === "SCORE") {
											quInput = quCoItem.find(".dwScoreOptionId");
											var curScore = quCoItem.find(".scoreNumInput").val();
											if(curScore != "") {
												logicStatus = (geLe === "le" && curScore <= scoreNum) || (geLe === "ge" && curScore >= scoreNum);
											}
											curQuItemId = quInput.val();
										} else if(quType === "MULTIFILLBLANK") {
											quInput = quCoItem.find(".dwMFillblankOptionId");
											logicStatus = quCoItem.find(".dwMFillblankInput").val() != "";
											curQuItemId = quInput.val();
										} else if(quType === "CHENRADIO") {
											quInput = quCoItem.find("input[type='radio']");
											logicStatus = quInput.prop("checked");
											curQuItemId = quCoItem.find(".dwChenInputTemp").val();
										} else if(quType === "CHENCHECKBOX") {
											quInput = quCoItem.find("input[type='checkbox']");
											logicStatus = quInput.prop("checked");
											curQuItemId = quCoItem.find(".dwChenInputTemp").val();
										} else if(quType === "CHENFBK") {
											quInput = quCoItem.find(".dwChenMFillblankInput");
											logicStatus = quInput.val() != "";
											curQuItemId = quCoItem.find(".dwChenInputTemp").val();
										}
										if(curQuItemId === cgQuItemId) {
											if(logicType === "1") {
												//跳转
												if(logicStatus) {
													//逻辑选项被选中状态，激活状态
													skQuestion(quItemBody.next(), skQuId, logicId, function() {
														//重新编题号
													});
													if(skQuId === "1" || skQuId === "2") {
														isbreak = true;
													}
												} else {
													var hidQuItemBodys = $(".hidFor" + logicId);
													$(".hidFor" + logicId).removeClass("hidFor" + logicId);
													$.each(hidQuItemBodys, function() {
														var thQuItemBodyClass = $(this).attr("class");
														if(thQuItemBodyClass.indexOf("hidFor") < 0) {
															$(this).show();
															//回答标记与逻辑设置没有关系
															$(this).find(".answerTag").attr("disabled", false);
														}
													});
												}
											} else {
												//逻辑类型为“显示” quType=2
												if(logicStatus) {
													//逻辑选项被选中状态，激活状态  显示题
													var hidQuItemBodys = $(".hidFor" + logicId);
													$(".hidFor" + logicId).removeClass("hidFor" + logicId);
													$.each(hidQuItemBodys, function() {
														var thQuItemBodyClass = $(this).attr("class");
														if(thQuItemBodyClass.indexOf("hidFor") < 0) {
															$(this).show();
															$(this).find(".answerTag").attr("disabled", false);
														}
													});
												} else {
													//隐藏题
													var hidQuItemBody = $(".quId[value='" + skQuId + "']").parents(".li_surveyQuItemBody");
													hidQuItemBody.hide();
													hidQuItemBody.addClass("hidFor" + logicId);
													hidQuItemBody.find(".answerTag").attr("disabled", true);
												}
											}
											return false;
										}
									});
									if(isbreak) {
										return false;
									}
								});
							} else if(quType === "FILLBLANK") {
								//遍历每个逻辑设置
								var quOptionItems = quItemBody.find(".dwQuOptionItemContent");
								var thVal = thFormElementObj.val();
								$.each(quLogicItems, function() {
									var loginItem = $(this);
									var cgQuItemId = loginItem.find(".cgQuItemId").val();
									var skQuId = loginItem.find(".skQuId").val();
									var logicId = loginItem.find(".logicId").val();
									var logicType = loginItem.find(".logicType").val();
									if(logicType === "1") {
										//跳转
										if(thVal != "") {
											//逻辑选项被选中状态，激活状态
											skQuestion(quItemBody.next(), skQuId, logicId, function() {
												//重新编题号
											});
											if(skQuId === "1" || skQuId === "2") {
												isbreak = true;
											}
										} else {
											//逻辑选项未被选中状态，未激活
											var hidQuItemBodys = $(".hidFor" + logicId);
											$(".hidFor" + logicId).removeClass("hidFor" + logicId);
											$.each(hidQuItemBodys, function() {
												var thQuItemBodyClass = $(this).attr("class");
												if(thQuItemBodyClass.indexOf("hidFor") < 0) {
													$(this).show();
													//回答标记与逻辑设置没有关系
													$(this).find(".answerTag").attr("disabled", false);
												}
											});
										}
									} else {
										//显示
										//逻辑类型为“显示” quType=1
										if(thVal != "") {
											//逻辑选项被选中状态，激活状态  显示题
											var hidQuItemBodys = $(".hidFor" + logicId);
											$(".hidFor" + logicId).removeClass("hidFor" + logicId);
											$.each(hidQuItemBodys, function() {
												var thQuItemBodyClass = $(this).attr("class");
												if(thQuItemBodyClass.indexOf("hidFor") < 0) {
													$(this).show();
													$(this).find(".answerTag").attr("disabled", false);
												}
											});
										} else {
											//隐藏题
											var hidQuItemBody = $(".quId[value='" + skQuId + "']").parents(".li_surveyQuItemBody");
											hidQuItemBody.hide();
											hidQuItemBody.addClass("hidFor" + logicId);
											hidQuItemBody.find(".answerTag").attr("disabled", true);
										}
									}
								});
							}
						}
					}

					function skQuestion(nextQuItemBody, skQuId, logicId, callback) {

						if(nextQuItemBody[0]) {
							var nextQuType = nextQuItemBody.find(".quType").val();
							var nextQuId = nextQuItemBody.find(".quId").val();
							var nextAnswerTag = nextQuItemBody.find(".answerTag");
							//判断跳转类型
							if(skQuId == null) {
								//对于逻辑选项未被选中的情况
							} else if(nextQuItemBody.is(":hidden")) {
								skQuestion(nextQuItemBody.next(), skQuId, logicId, function() {

								});
							} else if(nextQuType != "submitSurveyBtn" && nextQuType != "PAGETAG" && (skQuId === "1" || skQuId === "2" || nextQuId != skQuId)) {
								//对于逻辑项是被选定的情况下
								nextAnswerTag.attr("disabled", true);
								nextQuItemBody.hide();
								nextQuItemBody.addClass("hidFor" + logicId);
								skQuestion(nextQuItemBody.next(), skQuId, logicId, function() {});
							}
						} else {
							callback();
						}
					}

					resetQuNum();

					function resetQuNum() {
						var quCoNums = $(".quCoNum");
						$.each(quCoNums, function(i, item) {
							$(this).html((i + 1) + "、");
						});

					}

					/**********************处理答题进度条************************/
					function answerProgressbar(thObj) {
						var quItemBody = thObj.parents(".li_surveyQuItemBody ");
						var quType = quItemBody.find(".quType").val();
						if(quType === "RADIO") {
							var checks = quItemBody.find("input[type='radio']:checked");
							if(checks[0]) {
								quItemBody.find(".answerTag").val(1);
							} else {
								quItemBody.find(".answerTag").val(0);
							}
						} else if(quType == "CHECKBOX") {
							var checks = quItemBody.find("input[type='checkbox']:checked");
							if(checks[0]) {
								quItemBody.find(".answerTag").val(1);
							} else {
								quItemBody.find(".answerTag").val(0);
							}
						} else if(quType === "FILLBLANK") {
							var thVal = thObj.val();
							if(thVal != "") {
								quItemBody.find(".answerTag").val(1);
							} else {
								quItemBody.find(".answerTag").val(0);
							}
						} else if(quType === "ORDERQU") {
							var orderByLabels = quItemBody.find(".quOrderByLeftUl label");
							if(!orderByLabels[0]) {
								quItemBody.find(".answerTag").val(1);
							} else {
								quItemBody.find(".answerTag").val(0);
							}
						} else if(quType === "SCORE") {
							var quScoreOptionTr = thObj.parents(".quScoreOptionTr");
							var scoreNumInput = quScoreOptionTr.find(".scoreNumInput");
							if(scoreNumInput.val() != "") {
								quScoreOptionTr.find(".answerTag").val(1);
							} else {
								quScoreOptionTr.find(".answerTag").val(0);
							}
						} else if(quType === "MULTIFILLBLANK") {
							var mFillblankTableTr = thObj.parents(".mFillblankTableTr");
							if(thObj.val() != "") {
								mFillblankTableTr.find(".answerTag").val(1);
							} else {
								mFillblankTableTr.find(".answerTag").val(0);
							}
						} else if(quType === "CHENRADIO") {
							var dwQuCoChenRowTr = thObj.parents(".dwQuCoChenRowTr");
							dwQuCoChenRowTr.find(".answerTag").val(1);
						} else if(quType === "CHENCHECKBOX") {
							var dwQuCoChenRowTr = thObj.parents(".dwQuCoChenRowTr");
							var checks = dwQuCoChenRowTr.find("input[type='checkbox']:checked");
							if(checks[0]) {
								dwQuCoChenRowTr.find(".answerTag").val(1);
							} else {
								dwQuCoChenRowTr.find(".answerTag").val(0);
							}
						} else if(quType === "CHENSCORE") {
							var dwQuScoreOptionItemContent = thObj.parents(".dwQuScoreOptionItemContent");
							if(thObj.val() != "0") {
								dwQuScoreOptionItemContent.find(".answerTag").val(1);
							} else {
								dwQuScoreOptionItemContent.find(".answerTag").val(0);
							}
						} else if(quType === "CHENFBK") {
							var dwQuChenFbkOptionItemContent = thObj.parents(".dwQuChenFbkOptionItemContent");
							if(thObj.val() != "") {
								dwQuChenFbkOptionItemContent.find(".answerTag").val(1);
							} else {
								dwQuChenFbkOptionItemContent.find(".answerTag").val(0);
							}
						}
						var totalQuSize = $(".answerTag:enabled").size();
						var answerTag1 = $(".answerTag[value='1']:enabled");
						var answerQuSize = 0;
						if(answerTag1[0]) {
							answerQuSize = answerTag1.size();
						}
						var newValue = parseInt(answerQuSize / totalQuSize * 100);
						//console.log(answerQuSize + "/" + totalQuSize + "=" + newValue);
						$("#resultProgressRoot .progress-label").text("完成度：" + newValue + "%");
						$("#resultProgress").progressbar("option", "value", newValue);
					}
					$("#mobileTdId").click(function() {
						$(this).next().slideToggle();
						return false;
					});

					var bfbFloat = 0;
					$("#resultProgress").progressbar({
						value: bfbFloat,
						orientation: "vertical"
					});

					function refreshAutoCode(codeImgId) {
						var ctx = $("#ctx").val();
						$("#" + codeImgId).attr("src", ctx + "/jcaptcha.action");
					}

					//判则判断 
//					var url = "${ctx}/response!ajaxCheckSurvey.action";
//					var data = "surveyId=${survey.id}";
//					$.ajax({
//						url: url,
//						data: data,
//						type: "post",
//						success: function(msg) {
//							var json = eval("(" + msg + ")");
//							if(json.isCheckCode === "3") {
//								$("#jcaptchaImgBody").show();
//							}
//
//							if(json.surveyStatus != "0") {
//								$("#fixedMsg").show();
//								$("#fixedMsg").html("您已经回答过此问卷！");
//								$("#submitSurvey").remove();
//								$("form").attr("action", "#");
//							}
//						}
//					});

				});
			});
		</script>
	</body>

</html>